<?php
define('__ROOT__', dirname(dirname(__FILE__))); 
include_once(__ROOT__.'/includes/header.php'); 
?>
<div class="span9">  
<ul class="breadcrumb">
	<li>
		<a href="<?php echo base_url('/home'); ?>">Home</a> <span class="divider">/</span>
	</li>
	<li>
		<a href="<?php echo base_url('/automobiles'); ?>">Car and Vehicles</a>
	</li>
	<?php if (isset($bookmark)): ?>
	<span class="divider">/</span>
	<li>
		<?php echo $bookmark; ?></a>
	</li>
	<?php endif;?>
</ul>
<form class="search_top_form" id="autoSearchfrm" method="post" action="<?php echo base_url('/automobiles/search'); ?>">						
        <ul>
            <li>
                <input type="text" placeholder="Keyword..." name="keyword" id="keyword" value="<?php echo isset($keyword) ? $keyword: null; ?>">
            </li>
            <li>
            	<?php $selected_brand = isset($brand) ? $brand: ''; ?>
                <?php echo form_dropdown('brands', $brands,'All brands ..', $selected_brand, 'class="dropdown_class" style="width: 160px; font-size: 13px" id="dropdown_autobrand"'); ?>
            </li>
            <li>
            	<?php $selected_type = isset($type) ? $type : '';?>
               <?php echo form_dropdown('types', $types, $selected_type, 'class="dropdown_class" style="width: 160px; font-size: 13px" id="dropdown_autotype"'); ?>
            </li>
            <li>
                <button class="btn btn-warning"><i class="icon-search icon-white"></i> Search Now</button>
                 <a href="<?php echo base_url('/automobiles'); ?>"><u>clear results</u></a>
            </li>
        </ul>
    </form>
    
<div class="main_content detail-product">	
	
<p class="pull-right"> 	Filter: 
	<a href="<?php echo base_url('automobiles'); ?>">All </a> | 
	<a href="<?php echo base_url('automobiles/browse/categoryID_1'); ?>">Sell </a>| 
	<a href="<?php echo base_url('automobiles/browse/categoryID_2'); ?>">Buy </a>| 
	<a href="<?php echo base_url('automobiles/browse/categoryID_3'); ?>">Rent </a></p>					
	<h3 class="title"><?php if (isset($selectedcatg))
									echo $selectedcatg . '- ';
									?>Found <?php echo $num_rows; ?> LISTINGS</h3>
	<?php foreach($autolist as $auto): ?>
		<div class="listing-item">
			<div class="row-fluid">	
				<div class="span8">
					<div class="featured-item">
						<div class="span3">
						<?php
							if (isset($auto->primary_image)){
								$url = '/assets/uploads/automobiles/' . $auto->primary_image;
							}else {
								$url = '/assets/uploads/dummy.png';
							}
							?>
							<a href="<?php echo site_url('automobiles/details/' . $auto->automobileID); ?>"><img src="<?php echo site_url($url); ?>" alt="<?php echo $auto->title; ?>" title="<?php echo $auto->title; ?>" class="img pull-left" width="140px" height="80px"></a>								
							<p>Pub: <?php echo date ("d/m/Y",strtotime($auto->posted_date)); ?><br/>
							 Ph: <strong><?php echo $auto->contact_no; ?></strong><br/>
							</p>
						</div>
						<div class="span8">
							
							<h5><a href="detail.html">
							<?php echo anchor(site_url('automobiles/details/' . $auto->automobileID), $auto->title, 'title=""'); ?>
							</a></h5>
							Model: <strong><?php echo $auto->model; ?></strong>,
							Body Style: <a href="<?php echo base_url('automobiles/browse/') .'/typeID_'. $auto->id;  ?>"><?php echo $auto->auto_type; ?></a>,
							Brand: <a href="<?php echo base_url('automobiles/browse/') .'/brandID_'. $auto->brand_id;  ?>"><?php echo $auto->brand_name; ?></a><br>
							<hr/>
							<span>
							<?php 
								$cleanDesc = strip_tags ($auto->description);
								$cleanDesc = (strlen($cleanDesc) > 200) ? substr($cleanDesc,0,199).'...' : $cleanDesc;
								echo $cleanDesc; 
							?><i>(<?php echo anchor(site_url('automobiles/details/' . $auto->automobileID), 'Read more', 'title=""'); ?>)</i>
							</span>
							
						</div>								
					</div>								
				</div>
				<div class="span4">
					<div class="other_info">
						<p> <span style="font-family: Tahoma,sans-serif,arial; font-size: 20px;"><?php  echo $auto->price; ?></span>&nbsp;<sup><?php echo $auto->price_denote; ?></sup>
						 <?php 
						if ($auto->is_negotiable){
								echo '<img src="' . site_url('assets/img/nego_button.gif') . '">';
							}
						?></p>
					</div>
					<hr/>
						<p>
							<a href="<?php echo base_url('automobiles/details/' . $auto->automobileID . '/#messagelink'); ?>"><button class="btn btn-small btn-primary"><i class="icon-envelope icon-white"></i> Contact Seller</button></a>
							<a href="<?php echo "tel:" . $auto->contact_no; ?>"><button class="btn btn-small btn-primary"><i class="icon-volume-up icon-white"></i> Click to Call</button></a>
						</p>
				</div>
			</div>
		</div>
		<?php endforeach; ?>
			<?php if (strlen($pagination)): ?>
			   <div>
				Pages: <?php echo $pagination; ?>
			   </div>
		<?php endif; ?>
</div>
</div>
<?php
include_once(__ROOT__.'/includes/rightnav.php'); 
include_once(__ROOT__.'/includes/footer.php'); 
?>
 <script type="text/javascript">
	//$(".collapse").collapse();
		//$('#accordion').collapse({hide: true});
		$('#collapseThree').collapse('show');		
 </script>
